//
//
//  @ Project : AgriMarketSystem
//  @ Date : 18/10/2013
//  @ Author : NTT
//
//

using System.Collections.Generic;
using System.Linq;
namespace AgriMarketService
{
    public class Product
    {
        private int productId;

        public int ProductId
        {
            get { return productId; }
            set { productId = value; }
        }
        private string productName;

        public string ProductName
        {
            get { return productName; }
            set { productName = value; }
        }
        private TypeOfProduct typeOfProduct;

        public TypeOfProduct TypeOfProduct
        {
            get { return typeOfProduct; }
            set { typeOfProduct = value; }
        }
        public Product() { }
        public Product(int productId, string productName, TypeOfProduct typeOfProduct)
        {
            this.productId = productId;
            this.productName = productName;
            this.typeOfProduct = typeOfProduct;
        }
        public static Product GetProductById(int productId)
        {
            List<Product> allProducts = GetAllProducts();
            Product product = (from tempProduct in allProducts where tempProduct.ProductId == productId select tempProduct).FirstOrDefault();
            return product;
        }
        public static List<Product> GetAllProducts()
        {
            return new List<Product>() {
                new Product(){ProductId=1,ProductName="Product 1",TypeOfProduct=TypeOfProduct.GetTypeById(1)}, 
                new Product(){ProductId=2,ProductName="Product 2",TypeOfProduct=TypeOfProduct.GetTypeById(2)},
                new Product(){ProductId=3,ProductName="Product 3",TypeOfProduct=TypeOfProduct.GetTypeById(3)},
                new Product(){ProductId=4,ProductName="Product 4",TypeOfProduct=TypeOfProduct.GetTypeById(4)},
                new Product(){ProductId=5,ProductName="Product 5",TypeOfProduct=TypeOfProduct.GetTypeById(5)},
            };
        }
    }
}